﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FanPages.Server.Services.Contracts;
using FanPages.Server.Services;
using FanPages.Common;
using FanPages.Server.Services.Contracts.Dto;
using FanPages.Client.Core.Transformers;
using FanPages.Model;
using FanPages.Client.Gui.Desktop.Contracts;

namespace FanPages.Client.Gui.Desktop.Controllers
{
    public class FanItemController : IFanItemController
    {
        IFanItemService service = new FanItemService();

        public void Save(FanItem fanItem)
        {            
            ITransformer<FanItem, FanItemDto> transformer = new FanItemTransformer();
            service.Save(transformer.ToDto(fanItem));            
        }


        public List<FanItem> GetAll()
        {
            ITransformer<FanItem, FanItemDto> transformer = new FanItemTransformer();
            var items = new List<FanItem>();
            service.GetAll().ForEach(x => { items.Add(transformer.ToClient(x)); });
            return items;
        }
    }
}
